home *** CD-ROM | disk | FTP | other *** search
- /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Copyright (C) 1994, by WATCOM International Inc. All rights %
- % reserved. No part of this software may be reproduced or %
- % used in any form or by any means - graphic, electronic or %
- % mechanical, including photocopying, recording, taping or %
- % information storage and retrieval systems - except with the %
- % written permission of WATCOM International Inc. %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- */
-
- #ifndef _WBITMAP_HPP_INCLUDED
- #define _WBITMAP_HPP_INCLUDED
- #pragma once
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma pack(push,8);
- #pragma enum int;
- #endif
-
- #ifndef _WOBJECT_HPP_INCLUDED
- # include "wobject.hpp"
- #endif
- #ifndef _WARRAY_HPP_INCLUDED
- # include "warray.hpp"
- #endif
- #ifndef _WCOLOR_HPP_INCLUDED
- # include "wcolor.hpp"
- #endif
- #ifndef _WRESID_HPP_INCLUDED
- # include "wresid.hpp"
- #endif
- #ifndef _WICON_HPP_INCLUDED
- # include "wicon.hpp"
- #endif
- #ifndef _WPALETTE_HPP_INCLUDED
- # include "wpalette.hpp"
- #endif
- #ifndef _WBUFFER_HPP_INCLUDED
- # include "wbuffer.hpp"
- #endif
- #ifndef _WFILPATH_HPP_INCLUDED
- # include "wfilpath.hpp"
- #endif
-
- class WPoint;
- class WCanvas;
- class WBitmapReference;
-
- enum WStockBitmap {
- WSBitmapFirst,
- WSBitmapClose = WSBitmapFirst,
- WSBitmapUpArrow,
- WSBitmapDownArrow, WSBitmapDnArrow = WSBitmapDownArrow,
- WSBitmapLeftArrow, WSBitmapLfArrow = WSBitmapLeftArrow,
- WSBitmapRightArrow, WSBitmapRgArrow = WSBitmapRightArrow,
- WSBitmapReduce,
- WSBitmapZoom,
- WSBitmapRestore,
- WSBitmapCombo,
- WSBitmapMNArrow,
- WSBitmapSize,
- WSBitmapCheck,
- WSBitmapCheckBoxes,
- WSBitmapBtnCorners,
- WSBitmapBTSize,
- WSBitmapUpArrowD,
- WSBitmapDownArrowD, WSBitmapDnArrowD = WSBitmapDownArrowD,
- WSBitmapLeftArrowD, WSBitmapLfArrowD = WSBitmapLeftArrowD,
- WSBitmapRightArrowD, WSBitmapRgArrowD = WSBitmapRightArrowD,
- WSBitmapReduceD,
- WSBitmapZoomD,
- WSBitmapRestoreD,
- WSBitmapUpArrowI,
- WSBitmapDownArrowI, WSBitmapDnArrowI = WSBitmapDownArrowI,
- WSBitmapLeftArrowI, WSBitmapLfArrowI = WSBitmapLeftArrowI,
- WSBitmapRightArrowI, WSBitmapRgArrowI = WSBitmapRightArrowI,
-
- WSBitmapLastPlusOne,
- WSBitmapLast = WSBitmapLastPlusOne - 1,
- };
-
- class WCMCLASS WBitmap : public WObject {
- WDeclareSubclass( WBitmap, WObject );
-
- public:
-
- /**********************************************************
- * Constructors and Destructors
- *********************************************************/
-
- // Construct
-
- WBitmap();
- WBitmap( WStockBitmap bitmap );
- WBitmap( const WBitmap & src, WUInt newWidth=0, WUInt newHeight=0,
- WBool forceCreateNew=FALSE );
- WBitmap( const WResourceID & id, WModuleHandle module=_ApplicationModule );
- WBitmap( const WChar *file, const WResourceID & id,
- WBool loadLibraryAsDataOnly=FALSE );
- WBitmap( const WChar *file, WBool monochrome );
- WBitmap( WBitmapHandle hdl, WBool deleteHandle=FALSE );
- WBitmap( WDeviceHandle hdc, WUInt width, WUInt height );
- WBitmap( WUInt width, WUInt height, WUInt planes, WUInt bitsPerPel );
- WBitmap( const WIcon & icon, const WColor * backColor=NULL );
- WBitmap( const WIcon & icon, WCanvas * port, const WPoint & pt );
- WBitmap( const WIcon & icon, WCanvas * port );
- WBitmap( const WBuffer & buffer );
-
- // Destruct
-
- ~WBitmap();
-
- // Assignment
-
- WBitmap & operator=( const WBitmap & bitmap );
- WBitmap & operator=( WStockBitmap bitmap );
-
- // Equality
-
- int operator==( const WBitmap & bmp ) const;
- int operator!=( const WBitmap & bmp ) const;
-
- /************************************************************
- * Properties
- ************************************************************/
-
- // Handle
-
- WBitmapHandle GetHandle() const;
-
- // HandleDetached
-
- WBool GetHandleDetached() const;
-
- // Height
-
- WUInt GetHeight() const;
-
- // Palette
-
- WPalette GetPalette() const;
-
- // Valid
-
- WBool GetValid() const;
-
- // Width
-
- WUInt GetWidth() const;
-
- /************************************************************
- * Methods
- ************************************************************/
-
- // Clear
- //
- // Prepare the object for re-use. Deletes old bitmap
- // handle if appropriate.
-
- WBool Clear();
-
- // Create
- //
- // Create a new bitmap. Clears old one first.
-
- WBool Create( WStockBitmap bitmap );
- WBool Create( const WBitmap & src, WUInt newWidth=0,
- WUInt newHeight=0, WBool forceCreateNew=FALSE );
- WBool Create( const WResourceID & id, WModuleHandle module=_ApplicationModule );
- WBool Create( const WChar *file, const WResourceID & id,
- WBool loadLibraryAsDataOnly=FALSE );
- WBool Create( const WChar *file, WBool monochrome );
- WBool Create( WBitmapHandle hdl, WBool deleteHandle=FALSE );
- WBool Create( WDeviceHandle hdc, WUInt width, WUInt height );
- WBool Create( WUInt width, WUInt height, WUInt planes,
- WUInt bitsPerPel );
- WBool Create( const WIcon & icon, const WColor * backColor=NULL );
- WBool Create( const WIcon & icon, WCanvas * port, const WPoint & pt );
- WBool Create( const WIcon & icon, WCanvas * port );
- WBool Create( const WBuffer & buffer );
-
- // MakePalette
-
- WBool MakePalette();
-
- // DetachHandle
-
- WBool DetachHandle();
-
- // MapColor
-
- WBool MapColor( const WColor & mapFrom, const WColor & mapTo );
-
- // Save
- //
- // Save the bitmap out as a .BMP file.
-
- WBool Save( const WFilePath & filename, WUInt bitsPerPixel=0,
- WDeviceHandle dev=NULLHDEV ) const;
- WBool Save( WBuffer & buffer, WUInt bitsPerPixel=0,
- WDeviceHandle dev=NULLHDEV ) const;
-
- /***********************************************************
- * Static Properties
- ***********************************************************/
-
- // NullBitmap
-
- static const WBitmap & GetNullBitmap(); // not an empty bitmap...
-
- /************************************************************
- * Static Methods
- ************************************************************/
-
- // IsValidHandle
- //
- // Returns TRUE if the given handle is valid. Can
- // optionally specify whether or not a null handle
- // is "valid".
-
- static WBool IsValidHandle( WBitmapHandle handle,
- WBool nullValid=FALSE );
-
-
- /***********************************************************
- * Internal
- ***********************************************************/
-
- WUShort GetOriginalBitCount() const;
-
- protected:
- WBool GetWidthHeight();
-
- private:
- WBitmapReference * _bitmapRef;
- };
-
- extern template WArrayReference<WBitmap>;
- extern template WArray<WBitmap>;
- typedef WArray<WBitmap> WBitmapArray;
-
- #ifdef _DEBUG
- #define W_ISBITMAPHANDLE(h) CHECKGDI(WBitmap::IsValidHandle((WBitmapHandle)h))
- #else
- #define W_ISBITMAPHANDLE(h)
- #endif
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma enum pop;
- #pragma pack(pop);
- #endif
-
- #endif // _WBITMAP_HPP_INCLUDED
-